<template>
	<view class="ss-flex-col">
		<OrderMessage :info="info" />
		<uv-gap height="12"></uv-gap>
		<OrderInfoItem label="车牌号" :value="info.car_number" />
		<OrderInfoItem label="客户姓名" :value="info.c_name" />
		<OrderInfoItem label="客户电话" :value="info.c_mobile" />
		<OrderInfoItem label="行驶里程" :value="info.licheng" />
		<OrderInfoItem label="品牌" :value="info.brand_name" />
		<OrderInfoItem label="业务类型" :value="info.yewu_name" />
		<OrderInfoItem label="检测报告">
			<view @tap="bigImage(info.jiance_file)" class="ss-flex">
				<view class="fc-dark6 fs-28">查看检测报告</view>
				<z-icon name="arrow-right"></z-icon>
			</view>
		</OrderInfoItem>	
		<OrderInfoItem v-if="info.fujian_file" label="复检报告" :showB="false">
			<view @tap="bigImage(info.fujian_file)" class="ss-flex">
				<view class="fc-dark6 fs-28">查看复检报告</view>
				<z-icon name="arrow-right"></z-icon>
			</view>
		</OrderInfoItem>	
		<uv-gap height="12"></uv-gap>
		<RepairPlan isSelect :readOnly="readOnly" :modelValue="state.repairValueList" @change="getRepairValue" />
	</view>
</template>

<script setup>
	import sheep from "@/sheep"
	import OrderMessage from "./OrderMessage"
	import OrderInfoItem from "./OrderInfoItem"
	import RepairPlan from "./RepairPlan"
	import { watch } from 'vue'
	import DataTransformer  from "@/sheep/enu/DataTransformer.js"
	const props = defineProps({
		info: {
			type: Object,
			default: () => {
				return {}
			}
		},
		readOnly:{
			type:Boolean,
			default:false
		}
	})
	const emits = defineEmits(['change'])
	const state = reactive({
		repairValueList:''
	})
	// newRepairCase.push({
	// 	peijian:[],
	// 	tiaojiao:[],
	// 	remake:''
	// })
	watch(() => props.info, res => {
		let fanganlist = res.fanganlist || []
		const result = DataTransformer.transform(fanganlist)
		// const result = fanganlist.map(group => {
		//   const remake = group[0]?.remake || '';
		//   const peijian = group.filter(i => i.name.includes('配件'));
		//   const tiaojiao = group.filter(i => i.name.includes('调校'));
		//   return { peijian, tiaojiao, remake };
		// });
		// console.log(result,'000');
		state.repairValueList = JSON.stringify(result)
		emits('change',result)
		// console.log(result);
		// console.log(fanganlist,'详情');
		
	},{deep:true,immediate:true})
	function getRepairValue(e){
		state.repairValueList = JSON.stringify(e)
		emits('change',e)
	}
	function bigImage(url = ''){
		// let urls = [sheep.$url.cdn(url)]
		// console.log(urls);
		// uni.previewImage({
		// 	urls
		// })
		sheep.$helper.openDocument(url)
	}
</script>

<style>
</style>